package com.lucun.es_transaction.controller;

import com.lucun.es_transaction.config.RolePermission;
import com.lucun.es_transaction.entity.Coupon;
import com.lucun.es_transaction.service.CouponService;
import com.lucun.es_transaction.util.AuthorityUtil;
import com.lucun.es_transaction.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author: 郭鑫
 * @catalogue: com.lucun.es_transaction.controller
 * @Date: 2021/6/8 9:15
 * @Version: 1.0
 */
@RestController
@RequestMapping("/coupon")
public class CouponController {
    @Autowired
    CouponService couponService;

    @RolePermission(role = AuthorityUtil.THIRD)
    @RequestMapping("/findAll")
    public List<Coupon> FindAll(){
       return couponService.findAll();
    }

    @RolePermission(role = AuthorityUtil.SECOND)
    @RequestMapping("/insert")
    public JsonResult Insert(@RequestBody Coupon coupon, HttpServletRequest request){
        return couponService.insert(coupon,request);
    }

}
/*  cs */